<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<script>
function assert_throws_with_message(e, f, m) {
  try {
    f();
  } catch(exception) {
    assert_equals(exception.name, e);
    assert_equals(exception.message, m);
  }
}

test(function() {
  assert_throws_with_message('TypeError',
    function() {
      document.documentElement.animate([
        {offset: 0.6},
        {offset: 0.4}
      ]);
    },
    "Failed to execute 'animate' on 'Element': Offsets must be montonically non-decreasing."
  );

  assert_throws_with_message('TypeError',
    function() {
      document.documentElement.animate([
        {offset: 'a donkey'}
      ]);
    },
    "Failed to execute 'animate' on 'Element': Failed to read the 'offset' property from 'BaseKeyframe': The provided double value is non-finite."
  );

  assert_throws_with_message('TypeError',
    function() {
      document.documentElement.animate([
        {offset: -1}
      ]);
    },
    "Failed to execute 'animate' on 'Element': Offsets must be null or in the range [0,1]."
  );
});
</script>
